<script>
    $(function () {
        layui.use(['form','laydate', 'table'], function () {
            var form = layui.form,
                layer = layui.layer,
                laydate = layui.laydate,
                table = layui.table,
                $ = layui.$;

            /**
             * 初始化表单，要加上，不然刷新部分组件可能会不加载
             */
            form.render();

            laydate.render({
                elem:"#rsbApDate"
            });
            laydate.render({
                elem:"#rsbApBegintime"
            });
            laydate.render({
                elem:"#rsbApEndtime"
            });
            // 当前弹出层，防止ID被覆盖
            var parentIndex = layer.index;


            //监听提交
            form.on('submit(saveBtn)', function (data) {
                var datas=data.field;
                $.ajax({
                    url:"/insertApply",
                    method:'get',
                    data: datas,
                    dataType:"json",
                    success:function(data){
                        console.log(data);
                        if(data==1){
                            layer.alert("添加成功！");
                        }
                        if(data==2){
                            layer.alert("修改成功！");
                        }
                    }
                })
            });

        });

    })

</script>
<div class="layuimini-main">
    <div class="layui-form layuimini-form">
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label required">编号</label>
                <div class="layui-input-block">
                    <input  name="rsbApNum" id="rsbMonNum" lay-verify="required" lay-reqtext="编号不能为空" placeholder="请输入工资项编号"
                            class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">员工编号</label>
                <div class="layui-input-block">
                    <input  name="userNum" id="userNum" lay-verify="required" lay-reqtext="员工编号不能为空" placeholder="请输入员工编号"
                            class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">部门</label>
                <div class="layui-input-inline">
                    <select name="userDep" id="userDep" lay-verify="required" lay-reqtext="部门不能为空" >
                        <option></option>
                        <option value="人事部">人事部</option>
                        <option value="销售部">销售部</option>
                        <option value="生产部">生产部</option>
                        <option value="财务部">财务部</option>
                        <option value="研发部">研发部</option>
                        <option value="物资部">物资部</option>
                        <option value="无">无</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">员工姓名</label>
                <div class="layui-input-block">
                    <input  name="userName" id="userName" lay-verify="required" lay-reqtext="姓名不能为空" placeholder="请输入员工姓名"
                            class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">申请日期</label>
                <div class="layui-input-block">
                    <input type="text" name="rsbApDate"  id="rsbApDate" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">申请类型</label>
                <div class="layui-input-inline">
                    <select name="rsbApType" id="rsbApType" lay-verify="required" lay-reqtext="申请类型不能为空">
                        <option></option>
                        <option value="加班">加班</option>
                        <option value="请假">请假</option>
                        <option value="出差">出差</option>
                        <option value="离职">离职</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">加班时长/h</label>
                <div class="layui-input-block">
                    <input type="text" id="rsbApOvertime" name="rsbApOvertime" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">请假/出差天数</label>
                <div class="layui-input-block">
                    <input type="text" id="rsbApLong" name="rsbApLong"  class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">申请执行时间：</label>
                <div class="layui-input-block">
                    <input type="text" name="rsbApBegintime"  id="rsbApBegintime" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">申请结束时间：</label>
                <div class="layui-input-block">
                    <input type="text" name="rsbApEndtime"  id="rsbApEndtime" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">审批人</label>
                <div class="layui-input-block">
                    <input type="text" id="rsbApPeople" name="rsbApPeople"  class="layui-input">
                </div>
            </div>


            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">申请事由</label>
                <div class="layui-input-block">
                    <textarea name="rsbApReason" class="layui-textarea" placeholder="请输入申请事由"></textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </form>
    </div>
</div>